/* 
 * File:   AVLTreeAdapter.cpp
 * Author: Christopher
 * 
 * Created on November 12, 2012, 11:01 PM
 */

#include "AVLTreeAdapter.h"

AVLTreeAdapter::AVLTreeAdapter() {
}

/**
 * Insert a Term object pointer into the AVLTree
 * @param node Node object ptr to insert
 */
void AVLTreeAdapter::insert(Term* node) {
    tree.insert(node->getTerm(), node);
}

/**
 * Search the tree for a Term matching the given query
 * @param query search query string
 * @return a pointer to the term object or NULL if not found
 */
Term* AVLTreeAdapter::search(string query) {
    Term* found = tree.search(query);
    
    if(found == 0)
        return NULL;
    
    return found;
}

/**
 * Output a file containing the inverted file index
 * @param stream an ofstream reference to output to
 */
void AVLTreeAdapter::outputFile(ofstream &stream){
    tree.outputInvertedIndex(stream);
}